package WaiBao;

import java.util.Arrays;

public class ZhangYuZhen {
    public static void main(String[] args) {
        String[] name = {"贾探春(班长)", "余切(团支书)", "小李(学习委员)", "赵海玉(文艺委员)", "周杰", "杨涛涛", "李宜娟", "嘉葆通", "路亮亮", "刘冰", "丁家营", "刘永红",
                "康明秀", "刘涛丽", "上官梦", "立轴月", "李春梅", "王水云", "张天纯", "刘弯路", "李夏荣", "竹资源", "宁河", "李文", "张文柳", "张思思", "张斌安", "王猜题",
                "贾晓萌", "张玉珍(学生)"};//考生本人:张玉珍(学生)
        int[] age = {21,20, 22, 19, 19, 21, 19, 20, 18, 19, 18, 18, 19, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 19, 20, 21, 20};//最后一位：考生年龄:20

        double[] liwan1 = {77, 86, 84, 84, 89, 69, 74, 80, 84, 84, 81, 84, 85, 88, 88, 68, 70, 70, 76, 84, 92, 91, 95, 65, 75, 74, 94, 88, 84, 96};
        double[] liwan2 = {86, 84, 90, 76, 78, 74, 74, 79, 81, 74, 70, 77, 80, 80, 80, 64, 76, 79, 64, 98, 72, 71, 95, 86, 76, 84, 86, 75, 85, 95};
        double[] liwan3 = {90, 76, 84, 85, 74, 66, 68, 74, 84, 80, 73, 87, 85, 65, 85, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 74, 77, 89, 95};


        double gaoao1;//代表每个学生的总分
        double gaoao2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            gaoao1 =liwan1[i] + liwan2[i] +liwan3[i];
//            gaoao2 = (gaoao1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + gaoao1);
//            System.out.println(name[i] + "的平均分为:" + gaoao2);
//        }


//        double jixiang1 = 0,jixiang2 = 0;
//        double[] ruyi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            jixiang1= liwan1[i] + liwan2[i] + liwan3[i];
//            jixiang2 = (jixiang1* 1.0) / 3;
//            ruyi[i] =jixiang2;
//        }
//
//        for (int i = 0; i < ruyi.length - 1; i++) {
//            for (int j = 0; j <ruyi.length - i - 1; j++) {
//                if (ruyi[j] <ruyi[j + 1]) {
//                    double tep = ruyi[j];
//                    ruyi[j] =ruyi[j + 1];
//                    ruyi[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(ruyi[i]);
//        }




        double wenben1 = 0,wenben2 = 0,wenben3 = 0;//计算每门课的平均分
        double gequ1 = 0,gequ2 = 0,gequ3 = 0;//计算每门课标准差
        double wenjuan1 = 0,wenjuan2 = 0,wenjuan3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <liwan1.length; i++) {
            he +=liwan1[i];
        }
        wenben1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + wenben1);
        double Sum = 0;
        for (int i = 0; i < liwan2.length; i++) {
            Sum +=liwan2[i];
        }
        wenben2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +wenben2);
        double sum = 0;
        for (int i = 0; i <liwan3.length; i++) {
            sum +=liwan3[i];
        }
        wenben3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + wenben3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <liwan1.length; i++) {
            c1 += (liwan1[i] -wenben1) * (liwan1[i] - wenben1);
        }
        gequ1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + gequ1);
        for (int i = 0; i < liwan2.length; i++) {
            c2 += (liwan2[i] -wenben2) * (liwan2[i] -wenben2);
        }
        gequ2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +gequ2);

        for (int i = 0; i <liwan3.length; i++) {
            c3 += (liwan3[i] -wenben3) * (liwan3[i] -wenben3);
        }
        gequ3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + gequ3);
//////////////
        Arrays.sort(liwan1);
        Arrays.sort(liwan2);
        Arrays.sort(liwan3);
        wenjuan1 = (liwan1[14] +liwan2[15]) * 1.0 / 2;
        wenjuan2 = (liwan2[14] +liwan2[15]) * 1.0 / 2;
        wenjuan3 = (liwan3[14] +liwan3[15]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + wenjuan1);
        System.out.println("农业设施设计与制造的中位数为:" + wenjuan2);
        System.out.println("园艺植物设施栽培学的中位数为:" + wenjuan3);


    }
}
